package com.ximu.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @projectName: HomePage
 * @package: com.ximu.service_base.config
 * @className: MetaObjectHanlder
 * @author: ximu
 * @description: mybatis plus自动填充
 * @date: 2022/4/25 8:44
 * @version: 1.0
 */
@Component
public class MetaObjectHanlder implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("gmtCreate", new Date(), metaObject);
        this.setFieldValByName("gmtModified", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("gmtModified", new Date(), metaObject);
    }
}
